package one;

public class A020 {


    /**
     * 搜索二维矩阵
     * @param matrix
     * @param target
     * @return
     */
    public boolean searchMatrix(int[][] matrix, int target) {
        int m=matrix.length,n=matrix[0].length;
        int left=0,right=n-1;
        while(left<m && left>=0 && right<n && right>=0) {
            if(target > matrix[left][right]) left++;
            else if(target < matrix[left][right]) right--;
            else return true;
        }
        return false;
    }
}
